!
!  Merlin EVDO Support CCL
!	Author:	Kris Kreutzman & Russ Winsper
!
!	Copyright:	 1991-2004 Apple Computer, Inc.	All Rights Reserved.
!
!	revision history:
!       03/01/04    Adaptation for Novatel Merlin V620   DWA
!		03/03/04	Birth
!
@ORIGINATE

!
note "Starting Merlin EVDO Support CCL" 3
!
! ---- Initial modem setup ----
!
! Set serial port speed to 230400, 8 data bits and 1 stop bit
! 
!serreset 230400, 0, 8, 1
serreset 1843200, 0, 8, 1
!
hsreset 0 0 0 0 0 0
settries 0
!
@LABEL 1
!
! Get the modem's attention
!
matchclr
matchstr 1 3 "OK\13\10"
matchstr 2 101 "ERROR\13\10"
write "AT\13"
matchread 30
!
inctries
iftries 3 101
!
! Reset modem on failure - try again
!
dtrclear
pause 5
dtrset
flush
jump 1
!
@LABEL 3
!
settries 0
!
@LABEL 4
!
! Setup the modem for the following:
!   Echo off (E0)
!   Verbose result on (V1)
!   Reset to factory settings (&F)
!   Hang up on DTR on to off transition (&D2)
!   Track remote DCD (&C1)
!   Unix compatible DCD control (&C2)
!   Turn off answering (S0=0)
!
matchclr
matchstr 1 5   "OK\13\10"
matchstr 2 101 "ERROR\13\10"
!
!write "ATE0V1&F&D2&C1&C2S0=0\13"
write "AT\13"
matchread 30
!
inctries
iftries 3 101
!
! Reset the Modem on setup failure
!
DTRClear
pause 5
DTRSet
flush
jump 4
!
!
@LABEL 5
!
note "Connecting to Network" 3
!
write "ATD^7\13"
!
! ---- Connect -----
!
@LABEL 20
matchclr
matchstr  1 30  "CONNECT\13\10"
matchstr  2 30  "CONNECT "
matchstr  3 102 "NO DIALTONE\13\10"
matchstr  4 103 "NO CARRIER"
matchstr  5 103 "ERROR\13\10"
matchstr  6 104 "BUSY\13\10"
matchstr  7 105 "NO ANSWER\13\10"
matchstr  8 20  "CARRIER"
matchread 300
jump 101
!
! Set the standard connect message
!
@LABEL 30
note "Communicating at unknown rate" 2
!
CommunicatingAt 1843200
!
! Turn on CTS handshaking
!
hsreset 0 1 0 0 0 0
pause 5
!
exit 0
!
! ---- Hang up and reset modem ----
!
@HANGUP 
@LABEL 90 
settries 0
hsreset 0 0 0 0 0 0
!
@LABEL 91
! 
! Try to get control of the modem
! 
flush
pause 1
write "+++"
pause 1 
matchclr
matchstr 1 93 "OK\13\10"
matchread 30
!
@LABEL 93
! 
! hangup
! 
flush
matchclr
matchstr 1 99 "NO CARRIER\13\10"
matchstr 2 99 "OK\13\10"
matchstr 3 95 "ERROR\13\10"
!
write "ATH\13"
matchread 30
! 
! Try again to get control of the modem by toggling DTR
!
@LABEL 95
DTRClear
Pause 2
DTRSet
flush
!
! Try the hangup sequence three times otherwise declare an error
! 
inctries
iftries 3 101
jump 91
!
@LABEL 99
exit 0
!
! ---- Answer calls ----
!
@ANSWER
exit -6002 "Device does not support call answering."
!
! ---- Error messages ----
!
! Modem Not Responding
!
@LABEL 101
exit -6019
!
! No Dial Tone
!
@LABEL 102
exit -6020
!
! No Carrier or Error
!
@LABEL 103
exit -6021
!
! Busy
!
@LABEL 104
exit -6022
!
! No Answer
!
@LABEL 105
exit -6023
!
! User Cancellation
!
@LABEL 107
exit -6008
!
